<%@ include file="/common/taglibs.jsp"%>
<script type="text/javascript" src="<c:url value='/js/jquery/jquery.numeric.js'/>"></script>
<script type="text/javascript" src="<c:url value='/js/jquery/jquery.formatCurrency-1.4.0.pack.js'/>"></script>
<script src="<c:url value='/js/jquery/jqueryFileTree/jqueryFileTree.js' />" type="text/javascript"></script>
<script src="<c:url value='/js/file-browser.js' />" type="text/javascript"></script>
<link href="<c:url value='/js/jquery/jqueryFileTree/jqueryFileTree.css' />" rel="stylesheet" type="text/css" />
<link href="<c:url value='/css/dhtmlxcombo_paylineitem.css' />"	rel="stylesheet" type="text/css" />
<script type="text/javascript">
	$(document).ready(function() {

		$('#pageTitle').text('<spring:message code="editPartnergrant.heading" />');
		
		$('.dhx_combo_input').eq(0).focus();
		var dtOpts = { /*onClose: function() { this.focus(); }*/ };
	
// 		$("#projectStartDate").datepicker(dtOpts);
// 		$("#projectEndDate").datepicker(dtOpts);
// 		$("#overridePeriodStartDate").datepicker(dtOpts);
// 		$("#overridePeriodEndDate").datepicker(dtOpts);
// 		$("#receivedingrantsforapproval").datepicker(dtOpts);
		
		$('#chooseFileButton').click(function() {
			var fileBrowser = new FileBrowser('S:\\Scanned Documents','<c:url value="/js/jquery/jqueryFileTree/connectors/jqueryFileTree.jsp" />', 
				function(file) {
					$('#fileLocation').val(file);
				}
			);			
			fileBrowser.open();
		});

		$.validator.addMethod("drop_down_required", function(value, element) {
			return (value != "");
		}, "Please select an option.");
		
		$.validator.addMethod("dateValidation", 
                function(value, element) {
					 var date_ini = new Date($('#projectStartDate').val()).getTime();
					 var date_end = new Date($('#projectEndDate').val()).getTime();
					 if (date_ini > date_end) {
									return false;
								   }
						return true;
                     }, 
                    "The Partner Grant End date should be after Partner Grant Start Date."

		    );
			
			/*$.validator.addMethod("overrideValidation", 
	                function(value, element) {
						 if ($('input[name="override"]').prop('checked') && ($("#overrideAmount").val() == "" || $("#overridePeriodStartDate").val() == "" || $("#overridePeriodEndDate").val() == "")) {
										return false;
									   }
							return true;
	                     }, 
	                    "You must enter Budget Override Amount, Budget Override Period Start and End Dates."
			    );

			$.validator.addMethod("overridePeriodDateValidation", 
	                function(value, element) {
						 var date_ini = new Date($('#overridePeriodStartDate').val()).getTime();
						 var date_end = new Date($('#overridePeriodEndDate').val()).getTime();
						 if (date_ini > date_end) {
										return false;
									   }
							return true;
	                     }, 
	                    "The Partner Grant Budget Override Period End date should be after Partner Grant Budget Override Period Start Date."

			    );*/
		    

	
		$("#editPartnergrantForm").validate({			
			
			rules : {
				'partner.id' : {
					drop_down_required : true
				},
				'parentProject.id' : {
					drop_down_required : true
				},
				alphaidentifier : {
					drop_down_required : true
				},
				acronym : {
					required : true
				},
				costCenterNumber : {
					required : true
				},
				projectTitle : {
					required : true
				},
				partnerGrantStartDate : {
					required : true
					//greaterThan: "#projectStartDate"
				},
				partnerGrantEndDate : {
					required : true
					//greaterThan: "#projectEndDate"
				},
				'cipeprojectstatus.id' : {
					drop_down_required : true
				},
				projectStartDate : {
					required : true,
					greaterThan: "#partnerGrantStartDate",
					lessThan: "#partnerGrantEndDate"
				},
				projectEndDate : {
					required : true,
					dateValidation : true,
					greaterThan: "#partnerGrantStartDate",
					lessThan: "#partnerGrantEndDate"
				},
				/*overrideAmount : {
					required : false,
					overrideValidation : true
				},
				overridePeriodStartDate : {
					required : false,
					overrideValidation : true
				},
				overridePeriodEndDate : {
					required : false,
					overrideValidation : true,
					overridePeriodDateValidation : true
				},*/
				cipeprojecttype : {
					required : true
				},
				'region.id' : {
					drop_down_required : true
				},
				'country.id' : {
					drop_down_required : true
				},
				'seniorProgramOfficer.id' : {
					drop_down_required : true
				},
				'programOfficer.id' : {
					drop_down_required : true
				},
				'programAssistant.id' : {
					drop_down_required : true
				},
				//matchingFunds : {
					//required : true
				//},
				acronym : {
					required : true
				},
				projectTitle : {
					required : true
				},
				partnerGrantFunds : {
					required : true
				},
				fiscalYear: {
					required : true
				}
			}
		});

		$(".dhx_combo_input").rules("add", { 
  			required:true
		});
		
	       $("#submitFormButton").bind("click",function(){    
	    	   
	      		var t= setTimeout(function(){
	      		$('.dhx_combo_input').click();
	      		$('.input-full-width text_grey').click();
	      		},300);        
	      		
	      		if($('.dhx_combo_input').eq(0).val() == ''){
					 $('.dhx_combo_box ').eq(0).css("border-color", "#B50007");
					 }
			
	      		 $('.dhx_combo_input').eq(0).blur(function() {
	    			 if($('.dhx_combo_input').eq(0).val()!= ''){
	    				 $('.dhx_combo_box ').eq(0).css("border-color", "#BDBCBD");
	    			 }
	    		 });
	      		 $('.dhx_combo_input').eq(0).keypress(function(event) {
	   			  if ( event.which == 8 || event.which == 9  || event.which == 40) {
	   				  var inputVal = $('.dhx_combo_input').eq(0).val().length;
	   			 		if(inputVal == 1){
	   					 $('.dhx_combo_box ').eq(0).css("border-color", "#B50007");
	   					 }else if(inputVal == 0){
	   						 $('.dhx_combo_box ').eq(0).css("border-color", "#B50007");
	   					}else{
	   						 $('.dhx_combo_box ').eq(0).css("border-color", "#BDBCBD");
	   					 }
	   				   }
	   			});
	     		 
		 	if($('.dhx_combo_input').eq(1).val() == ''){
				 $('.dhx_combo_box ').eq(1).css("border-color", "#B50007");
				 }
		
	 		 $('.dhx_combo_input').eq(1).blur(function() {
				 if($('.dhx_combo_input').eq(1).val()!= ''){
					 $('.dhx_combo_box ').eq(1).css("border-color", "#BDBCBD");
				 }
			 });
	 		 $('.dhx_combo_input').eq(1).keypress(function(event) {
				  if ( event.which == 8 || event.which == 9  || event.which == 40) {
					  var inputVal = $('.dhx_combo_input').eq(1).val().length;
				 		if(inputVal == 1){
						 $('.dhx_combo_box ').eq(1).css("border-color", "#B50007");
						 }else if(inputVal == 0){
							 $('.dhx_combo_box ').eq(1).css("border-color", "#B50007");
						}else{
							 $('.dhx_combo_box ').eq(1).css("border-color", "#BDBCBD");
						 }
					   }
				});
	  		
			 	if($('.dhx_combo_input').eq(2).val() == ''){
					 $('.dhx_combo_box ').eq(2).css("border-color", "#B50007");
					 }
			
	  		 $('.dhx_combo_input').eq(2).blur(function() {
				 if($('.dhx_combo_input').eq(2).val()!= ''){
					 $('.dhx_combo_box ').eq(2).css("border-color", "#BDBCBD");
				 }
			 });
	  		 $('.dhx_combo_input').eq(2).keypress(function(event) {
				  if ( event.which == 8 || event.which == 9  || event.which == 40) {
					  var inputVal = $('.dhx_combo_input').eq(2).val().length;
				 		if(inputVal == 1){
						 $('.dhx_combo_box ').eq(2).css("border-color", "#B50007");
						 }else if(inputVal == 0){
							 $('.dhx_combo_box ').eq(2).css("border-color", "#B50007");
						}else{
							 $('.dhx_combo_box ').eq(2).css("border-color", "#BDBCBD");
						 }
					   }
				});
	  		 
	
			 	if($('.dhx_combo_input').eq(3).val() == ''){
					 $('.dhx_combo_box ').eq(3).css("border-color", "#B50007");
					 }
			
	  		 $('.dhx_combo_input').eq(3).blur(function() {
				 if($('.dhx_combo_input').eq(3).val()!= ''){
					 $('.dhx_combo_box ').eq(3).css("border-color", "#BDBCBD");
				 }
			 });
	  		 $('.dhx_combo_input').eq(3).keypress(function(event) {
				  if ( event.which == 8 || event.which == 9  || event.which == 40) {
					  var inputVal = $('.dhx_combo_input').eq(3).val().length;
				 		if(inputVal == 1){
						 $('.dhx_combo_box ').eq(3).css("border-color", "#B50007");
						 }else if(inputVal == 0){
							 $('.dhx_combo_box ').eq(3).css("border-color", "#B50007");
						}else{
							 $('.dhx_combo_box ').eq(3).css("border-color", "#BDBCBD");
						 }
					   }
				});
	 
	
			 	if($('.dhx_combo_input').eq(4).val() == ''){
					 $('.dhx_combo_box ').eq(4).css("border-color", "#B50007");
					 }
			
	  		 $('.dhx_combo_input').eq(4).blur(function() {
				 if($('.dhx_combo_input').eq(4).val()!= ''){
					 $('.dhx_combo_box ').eq(4).css("border-color", "#BDBCBD");
				 }
			 });
	  		 $('.dhx_combo_input').eq(4).keypress(function(event) {
				  if ( event.which == 8 || event.which == 9  || event.which == 40) {
					  var inputVal = $('.dhx_combo_input').eq(4).val().length;
				 		if(inputVal == 1){
						 $('.dhx_combo_box ').eq(4).css("border-color", "#B50007");
						 }else if(inputVal == 0){
							 $('.dhx_combo_box ').eq(4).css("border-color", "#B50007");
						}else{
							 $('.dhx_combo_box ').eq(4).css("border-color", "#BDBCBD");
						 }
					   }
				}); 
	
	  		if($('.dhx_combo_input').eq(5).val() == ''){
				 $('.dhx_combo_box ').eq(5).css("border-color", "#B50007");
				 }
		
			 $('.dhx_combo_input').eq(5).blur(function() {
			 if($('.dhx_combo_input').eq(5).val()!= ''){
				 $('.dhx_combo_box ').eq(5).css("border-color", "#BDBCBD");
			 }
		 });
			 $('.dhx_combo_input').eq(5).keypress(function(event) {
			  if ( event.which == 8 || event.which == 9  || event.which == 40) {
				  var inputVal = $('.dhx_combo_input').eq(5).val().length;
			 		if(inputVal == 1){
					 $('.dhx_combo_box ').eq(5).css("border-color", "#B50007");
					 }else if(inputVal == 0){
						 $('.dhx_combo_box ').eq(5).css("border-color", "#B50007");
					}else{
						 $('.dhx_combo_box ').eq(5).css("border-color", "#BDBCBD");
					 }
				   }
			}); 
	  		 
			 	if($('.dhx_combo_input').eq(6).val() == ''){
					 $('.dhx_combo_box ').eq(6).css("border-color", "#B50007");
					 }
			
	  		 $('.dhx_combo_input').eq(6).blur(function() {
				 if($('.dhx_combo_input').eq(6).val()!= ''){
					 $('.dhx_combo_box ').eq(6).css("border-color", "#BDBCBD");
				 }
			 });
	  		 $('.dhx_combo_input').eq(6).keypress(function(event) {
				  if ( event.which == 8 || event.which == 9  || event.which == 40) {
					  var inputVal = $('.dhx_combo_input').eq(6).val().length;
				 		if(inputVal == 1){
						 $('.dhx_combo_box ').eq(6).css("border-color", "#B50007");
						 }else if(inputVal == 0){
							 $('.dhx_combo_box ').eq(6).css("border-color", "#B50007");
						}else{
							 $('.dhx_combo_box ').eq(6).css("border-color", "#BDBCBD");
						 }
					   }
				});
	  		if($('.dhx_combo_input').eq(7).val() == ''){
				 $('.dhx_combo_box ').eq(7).css("border-color", "#B50007");
				 }
		
			 $('.dhx_combo_input').eq(7).blur(function() {
			 if($('.dhx_combo_input').eq(7).val()!= ''){
				 $('.dhx_combo_box ').eq(7).css("border-color", "#BDBCBD");
			 }
		 });
			 $('.dhx_combo_input').eq(7).keypress(function(event) {
			  if ( event.which == 8 || event.which == 9  || event.which == 40) {
				  var inputVal = $('.dhx_combo_input').eq(7).val().length;
			 		if(inputVal == 1){
					 $('.dhx_combo_box ').eq(7).css("border-color", "#B50007");
					 }else if(inputVal == 0){
						 $('.dhx_combo_box ').eq(7).css("border-color", "#B50007");
					}else{
						 $('.dhx_combo_box ').eq(7).css("border-color", "#BDBCBD");
					 }
				   }
			});
			 
			 if($('.dhx_combo_input').eq(8).val() == ''){
				 $('.dhx_combo_box ').eq(8).css("border-color", "#B50007");
			 }
	
		 $('.dhx_combo_input').eq(8).blur(function() {
		 if($('.dhx_combo_input').eq(8).val()!= ''){
			 $('.dhx_combo_box ').eq(8).css("border-color", "#BDBCBD");
		 }
	});
		 
		 $('.dhx_combo_input').eq(8).keypress(function(event) {
		  if ( event.which == 8 || event.which == 9  || event.which == 40) {
			  var inputVal = $('.dhx_combo_input').eq(8).val().length;
		 		if(inputVal == 1){
				 $('.dhx_combo_box ').eq(8).css("border-color", "#B50007");
				 }else if(inputVal == 0){
					 $('.dhx_combo_box ').eq(8).css("border-color", "#B50007");
				}else{
					 $('.dhx_combo_box ').eq(8).css("border-color", "#BDBCBD");
				 }
			   }
		});
		 
		 if($('.dhx_combo_input').eq(9).val() == ''){
			 $('.dhx_combo_box ').eq(9).css("border-color", "#B50007");
		 }
	
	 $('.dhx_combo_input').eq(9).blur(function() {
	 if($('.dhx_combo_input').eq(9).val()!= ''){
		 $('.dhx_combo_box ').eq(9).css("border-color", "#BDBCBD");
	 }
	});
	 $('.dhx_combo_input').eq(9).keypress(function(event) {
	  if ( event.which == 8 || event.which == 9  || event.which == 40) {
		  var inputVal = $('.dhx_combo_input').eq(9).val().length;
	 		if(inputVal == 1){
			 $('.dhx_combo_box ').eq(9).css("border-color", "#B50007");
			 }else if(inputVal == 0){
				 $('.dhx_combo_box ').eq(9).css("border-color", "#B50007");
			}else{
				 $('.dhx_combo_box ').eq(9).css("border-color", "#BDBCBD");
			 }
		   }
	});
	 
 });

		$("#partnerGrantFunds").numeric();
		$("#partnerGrantFundsDis").numeric();
		$("#matchingFunds").numeric();
		$("#matchingFundsDis").numeric();
		//$("#overrideAmount").numeric();
		//$("#overrideAmountDis").numeric();
	
		
		
		$('#edit-donoraward').click(function() {
			var sel = document.getElementById("donorawardId");
			if(sel.selectedIndex >= 0) {
				var idVal = sel.options[sel.selectedIndex].value;
				if (idVal != 0) {
					loadDiv('content', 'showEditDonoraward.do?id=' + idVal);
				};
			};	
		});
		
		$('#view-cipeprojectsummary').click(function() {
			loadDiv('content', 'showCipeprojectSummary.do?id=' + $(this).attr('cipeprojectId'));
		});
		$('#add-reporting').click(function() {
			loadDiv('content', 'showAddReportingrequirements.do');
		});
		$('#add-partnermonitoring').click(function() {
			loadDiv('content', 'auditsForm.do?cipeprojectId=${cipeproject.id}');
		});		
		
		$('.close-button').click(function() {
			if(confirm('Are you sure you want to close the form?')) {
				window.location = '../secure/showDashboard.do';
			}
	     });
		
		$('#cancelButton').click(function() {
			var ans = confirm('Are you sure you want to cancel editing this record without saving it?');
			if (ans) {
				location.href = '../secure/showDashboard.do';
			}
		});	
		
		sortDropDownListByText();
		
		<c:if test="${!empty mode && 'addPartnerGrant' == mode}">              
		$('#showConfirmAddNarativeReport').click(function() {
  			$('<div>Would you like to enter Financial and Narrative Reporting at this time?<br/></div>').dialog({
                dialogClass: 'confirmAddNarativeReportDialog',
                title: 'Add Reporting Information?',
                width: 310,
                modal: true,
                resizable: false,
 				buttons: 
 		          {
 					'Yes' : function() {
 						$(this).dialog('close');
 						$('#addNarativeReport').val('addNarativeReport');
 						$('#submitFormButton').click();
 					},
 					'No' : function() {
 						$(this).dialog('close');
 						$('#addNarativeReport').val('');
 						$('#submitFormButton').click();
 					}
 		          }
              });
  			return false;
  		});		
		</c:if>	

		$("#partnergrantFormSubmit").attr("disabled","disabled");	
		$("#partnergrantFormSubmit").attr("class", "gray_btn");	
		
		<c:if test="${cipeproject.id !=null and cipeproject.id gt 0}">
		toggleViewEditMode(true);
		getConcatenateCostCenter();
		$('#partnerGrantFundsDis').val($('#partnerGrantFunds').val().replace(/[^0-9\.]+/g,""));
		$('#matchingFundsDis').val($('#matchingFunds').val().replace(/[^0-9\.]+/g,""));
		$('#matchingFundsDis').formatCurrency({colorize: true, negativeFormat: '-%s%n', roundToDecimalPlace: 2});
		calcTotalFunds();
		$('#partnerGrantFundsDis').formatCurrency({colorize: true, negativeFormat: '-%s%n', roundToDecimalPlace: 2});
		$('#totalDisbursedAmount').formatCurrency({colorize: true, negativeFormat: '-%s%n', roundToDecimalPlace: 2});
		//$('#overrideAmountDis').val($('#overrideAmount').val().replace(/[^0-9\.]+/g,""));
		//$('#overrideAmountDis').formatCurrency({colorize: true, negativeFormat: '-%s%n', roundToDecimalPlace: 2});
		</c:if>
		<c:if test="${cipeproject.id==null }">
			$("#projectStartDate").datepicker();
			$("#projectEndDate").datepicker();
			//$("#overridePeriodStartDate").datepicker();
			//$("#overridePeriodEndDate").datepicker();
			$("#receivedingrantsforapproval").datepicker();
		</c:if>
		onChangeParentProjectId();
	});
	//end of document ready
		<c:if test="${cipeproject.id !=null and cipeproject.id gt 0}">
		function toggleInputOrSelectElement(viewMode,elements) {
			
    		for(var i = 0; i < elements.length; i++) {
    			elements[i].readonly = viewMode;
    			var className = '';
    			if(viewMode) {
    				className = 'text_grey';
    				if(elements[i].className.indexOf("input-full-width-req") != -1) {
    					className = 'input-full-width-req ' + className;	
    				}else if(elements[i].className.indexOf("dhx_combo_input")!=-1)
    					className = className+' input-full-width-req ' ;	
    			} else {
    				if(elements[i].className.indexOf("input-full-width-req") != -1) {
    					className += 'input-full-width-req text_blue';	
    				} 
    				else if(elements[i].className.indexOf("dhx_combo_input")!=-1)
    					className += 'input-full-width-req text_blue';
    				else {
    					className += 'text_white';
    				}
    			}
    			elements[i].className = className;
    		}
    	}
    	
  
    	
    	function toggleViewEditMode(viewMode) {
    		var inputs = $('#editPaymentPartnerInfo input[type="text"]:not(.uneditable)');
    		var selects = $('#editPaymentPartnerInfo select:not(.uneditable)');
//     		var textareas = $('#editPaymentPartnerInfo textarea:not(.uneditable)');
    		toggleInputOrSelectElement(viewMode,inputs);
    		
    		if(viewMode)
    		{
    			z1.readonly(true,false);
    			z2.readonly(true,false);
    			z3.readonly(true,false);   
    			z4.readonly(true,false);
    			z5.readonly(true,false);
    			z6.readonly(true,false); 
    			z7.readonly(true,false); 

    			$("#projectStartDate").datepicker("disable");
    			$("#projectEndDate").datepicker("disable");

    			//$("#overridePeriodStartDate").datepicker("disable");
    			//$("#overridePeriodEndDate").datepicker("disable");

    			$("#receivedingrantsforapproval").datepicker("disable");
    			
    			$("#partnerGrantFundsDis").attr("readonly","readonly");
    			$("#matchingFundsDis").attr("readonly","readonly");
    			//$("#overrideAmountDis").attr("readonly","readonly");
    			$("#fileLocation").attr("readonly","readonly");
    			$("#memo").attr("readonly","readonly");
    			$("#fiscalYear").attr("readonly","readonly");

            	selects.each(function(){ 
            		$(this).attr("disabled","disabled");
            	});
    		}else{
    			z1.readonly(false,true);
    			z2.readonly(false,true);
    			z3.readonly(false,true);   
    			z4.readonly(false,true);
    			z5.readonly(false,true);
    			z6.readonly(false,true); 
    			z7.readonly(false,true);
    			selects.each(function(){ 
            		$(this).removeAttr("disabled");
            	});
    			$("#projectStartDate").datepicker();
    			$("#projectEndDate").datepicker();

    			//$("#overridePeriodStartDate").datepicker();
    			//$("#overridePeriodEndDate").datepicker();

    			$("#receivedingrantsforapproval").datepicker();
    			
    			$("#partnerGrantFundsDis").removeAttr("readonly");
    			$("#matchingFundsDis").removeAttr("readonly");
    			//$("#overrideAmountDis").removeAttr("readonly");
    			$("#fileLocation").removeAttr("readonly");
    			$("#memo").removeAttr("readonly");
    			$("#fiscalYear").removeAttr("readonly");

    			
    		}    
    	
    	}
	</c:if>
	
		$("#regions").bind("change", function() {
			onChangeRegion();
		});
		
		function onChangeRegion(){
			loadDataViaAjax("loadCountries.do", {
				"regionId" : $("#regions").val()
			}, parseCountriesJson);
			
		}
		
		$("#partnerGrantFunds").bind("change", calcTotalFunds);
		$("#matchingFunds").bind("change", calcTotalFunds).trigger("change");

		$("#partnerGrantStartDate").bind("change", getFiscalYear);

		$("#countries").bind("change", function() {
			loadDataViaAjax("loadCountryUsers.do", {
				"countryId" : this.value
			}, function(result) {
	 			z4.setComboValue(result.programOfficer ? result.programOfficer : "");
	 			z6.setComboValue(result.programAssistant ? result.programAssistant : "");
			});
		});
		

	function getFiscalYear() {
		var str1 = document.getElementById("partnerGrantStartDate").value;
		var mon1 = parseInt(str1.substring(0, 2), 10);
		var dt1 = parseInt(str1.substring(3, 5), 10);
		var yr1 = parseInt(str1.substring(6, 10), 10);
		var dt2 = 1;
		var mon2 = 10;

		var date1 = new Date(yr1, mon1, dt1);
		var date2 = new Date(yr1, mon2, dt2);

		if (isNaN(yr1)) {
			//do nothing
		} else {

			if (date1 >= date2) {
				document.getElementById("fiscalYear").value = yr1 + 1;
			} else {
				document.getElementById("fiscalYear").value = parseInt(yr1);
			}
		}
	}

	function parseDateString(src) {
		if (src != null && src != "") {
			var mon = parseInt(src.substring(0, 2), 10);
			var dt = parseInt(src.substring(3, 5), 10);
			var yr = parseInt(src.substring(6, 10), 10);
			return new Date(yr, mon, dt);
		}
		return null;
	}


	function getConcatenateCostCenter() {
		var str1 =z3.getSelectedText();
		str1 = str1.slice(0, str1.indexOf('|')-1);
        var str2=z5.getSelectedText();
		var prIdDisTxt = document.getElementById("projectIDDis");
		prIdDisTxt.value = (str1 != "" && str2 != "") ? (str1 + str2) : "";
		document.getElementById("projectID").value = prIdDisTxt.value;
	}
	function calcTotalFunds() {
		var fundsAmnt = $.trim($("#partnerGrantFunds").val());
		var matchAmnt = $.trim($("#matchingFunds").val());
		var x1 = (fundsAmnt != "") ? ((isNaN(fundsAmnt) ? 0 : parseFloat(fundsAmnt))) : 0;
		var x2 = (matchAmnt != "") ? ((isNaN(matchAmnt) ? 0 : parseFloat(matchAmnt))) : 0;
		$("#totalDisbursedAmount").val(x1 + x2);
	}

	
	function parseDonorawardJson(data) {
		//var html = "<option value=''>Select</option>";
		var html = "";
		if (data) {
			for (p in data) {
				html += "<option value='" + p + "'>" + data[p] + "</option>";
			}
			$("#donorawardId").val(data[p]);
			$("#donorawardRefId").val(p);
			
		}
		//$("#donorawardId option").remove(); // for drop-down
		//$("#donorawardId").append(html); // for drop-down
	}
	
	function sortDropDownListByText() {
		// Loop for each select element on the page.

		$("select").each(function() {

			// Keep track of the selected option.
			var selectedValue = $(this).val();
			// Sort all the options by text.
			$(this).html($("option", $(this)).sort(function(a, b) {
				return a.text == b.text ? 0 : ((a.text < b.text) || a.text != '') ? -1 : 1;
			}));

			// Select one option.
			$(this).val(selectedValue);
		});
	}
	
	$('#partnerGrantFundsDis').blur(function(){
		$('#partnerGrantFunds').val($('#partnerGrantFundsDis').val().replace(/[^0-9\.]+/g,""));
		calcTotalFunds();
		$('#partnerGrantFundsDis').formatCurrency({colorize: true, negativeFormat: '-%s%n', roundToDecimalPlace: 2});
		$('#totalDisbursedAmount').formatCurrency({colorize: true, negativeFormat: '-%s%n', roundToDecimalPlace: 2});
	});
	
	$('#matchingFundsDis').blur(function(){
		$('#matchingFunds').val($('#matchingFundsDis').val().replace(/[^0-9\.]+/g,""));
		calcTotalFunds();
		$('#matchingFundsDis').formatCurrency({colorize: true, negativeFormat: '-%s%n', roundToDecimalPlace: 2});
		$('#totalDisbursedAmount').formatCurrency({colorize: true, negativeFormat: '-%s%n', roundToDecimalPlace: 2});
	});
	
	/*$('#overrideAmountDis').blur(function(){
		$('#overrideAmount').val($('#overrideAmountDis').val().replace(/[^0-9\.]+/g,""));
		$('#overrideAmountDis').formatCurrency({colorize: true, negativeFormat: '-%s%n', roundToDecimalPlace: 2});
	});*/
	
	jQuery.validator.addMethod("greaterThan", 
			function(value, element, params) {

			    if (!/Invalid|NaN/.test(new Date(value))) {
			        return new Date(value) >= new Date($(params).val());
			    }

			    return isNaN(value) && isNaN($(params).val()) 
			        || (parseFloat(value) >= parseFloat($(params).val())); 
			},'Must be greater than or equal to Project Start Date.');
	
	jQuery.validator.addMethod("lessThan", 
			function(value, element, params) {

			    if (!/Invalid|NaN/.test(new Date(value))) {
			        return new Date(value) <= new Date($(params).val());
			    }

			    return isNaN(value) && isNaN($(params).val()) 
			        || (parseFloat(value) <= parseFloat($(params).val())); 
			},'Must be less than or equal to Project End Date.');
	
	//matchingFundsDis
	
	
	

	$('#editButton').click(function() {
		<c:if test="${cipeproject.id !=null and cipeproject.id gt 0}">
		toggleViewEditMode(false);
		</c:if>
		$("#partnergrantFormSubmit").removeAttr("disabled","disabled");	
		$("#partnergrantFormSubmit").attr("class", "blue_btn");
		$("#editButton").attr("disabled","disabled");
		$("#editButton").attr("class", "gray_btn");	
		
	});
	

	function parseCountriesJson(data) {
		var html = "<option value=''>Select</option>";
		var directorId = "";
		if (data) {
			for (p in data) {
				if(p != 'director') { 
					html += "<option value='" + p + "'>" + data[p] + "</option>";
				} else {
					directorId = data[p];
				}
			}
		}
		$("#countries option").remove();
		$("#countries").append(html).trigger("change");
		z2.setComboValue(directorId);
		sortDropDownListByText();
	}
	
	var z1 = dhtmlXComboFromSelect("partner",246/*316*/);
	z1.enableFilteringMode(true);
	var z2 = dhtmlXComboFromSelect("seniorProgramOfficer",316);
	z2.enableFilteringMode(true);
	var z3 = dhtmlXComboFromSelect("parentProjectId",316);
	z3.enableFilteringMode(true);
	z3.attachEvent("onChange",function(){
		onChangeParentProjectId();
	});
	
	function onChangeParentProjectId(){
	       getConcatenateCostCenter();
			if ($("input[name='parentProject.id']").val() != '' ) {
				loadDataViaAjax("getCipeprojectBean.do", {
					"cipeprojectId" : $('[name="parentProject.id"]').val()
				}, function(bean) {
					
					$('#partnerGrantStartDate').val(bean.formattedStartDate);
					$('#partnerGrantEndDate').val(bean.formattedEndDate);
					$('#nedIdentifier').val(bean.nedIdentifier);
					$('#donorId').val(bean.donorName);
					$('#acronym').val(bean.acronym);
					$('#projectTitle').val(bean.title);
					$('#costCenterNumber').val(bean.costCenterNumber);		
					$('#regions').val(bean.region);
			        $('#countries').val(bean.country);
                   z2.setComboValue(bean.seniorProgramOfficer);
			        z4.setComboValue(bean.programOfficer);
			        z6.setComboValue(bean.programAssistant);
					parseDonorawardJson(bean.donoraward);
					$("#partnerGrantStartDate").trigger("change");
				});
			} else {
				$('#partnerGrantStartDate').val('');
				$('#partnerGrantEndDate').val('');
				$('#nedIdentifier').val('');
				$('#donorId').val('');
				$('#acronym').val('');
				$('#projectTitle').val('');
				$('#costCenterNumber').val('');
				$('#projectID').val('');
				$('#projectIDDis').val('');
				parseDonorawardJson(null);
			}
			;
	}
	var z4 = dhtmlXComboFromSelect("programOfficer",316);
	z4.enableFilteringMode(true);
	var z5 = dhtmlXComboFromSelect("alphaidentifier",316);
	z5.enableFilteringMode(true);
	z5.attachEvent("onChange",function(){
        getConcatenateCostCenter();		
	});
   	var z6 = dhtmlXComboFromSelect("programAssistant",316);
	z6.enableFilteringMode(true);
	var z7 = dhtmlXComboFromSelect("status",316);
	z7.enableFilteringMode(true);

	
</script>
<div id="editPartnergrantDiv">
	<form:form name="editPartnergrantForm" id="editPartnergrantForm" action="savePartnergrant.do" method="post" modelAttribute="cipeproject">
<%-- 		<form:hidden path="id" /> --%>
<%-- 		<form:hidden path="costCenterNumber" /> --%>
        <input type="hidden" name="addNarativeReport" id="addNarativeReport" />
	    <div class="main_form">
	    	<div class="form_head">
				<div class="floatL" style="padding-top:5px;">
					<c:choose>
			            <c:when test="${cipeproject.id !=null and cipeproject.id gt 0}">
					       <a href="#" id="view-cipeprojectsummary" class="blue_btn" cipeprojectId="${cipeproject.id}" tabindex="-1"><spring:message code="editPartnergrant.link.viewProject" /></a>
					       <a href="javascript:loadDiv('content', 'showAddReportingrequirements.do?cipeprojectId=${cipeproject.id}');" id="add-reporting" class="blue_btn" tabindex="-1"><spring:message code="editPartnergrant.link.reporting" /></a>
					       <a href="#" id="add-partnermonitoring" class="blue_btn" tabindex="-1"><spring:message code="editPartnergrant.link.partnerMonitoring" /></a> 
					    </c:when>
					    <c:otherwise>
					       <span id="add-reportingtemp" class="gray_btn" tabindex="-1"><spring:message code="editPartnergrant.link.reporting" /></span>
					      <!--   <a href="javascript:loadDiv('content', 'showAddReportingrequirements.do?cipeprojectId=2220');" id="add-reporting" class="blue_btn" tabindex="-1"><spring:message code="editPartnergrant.link.reporting" /></a>-->
					       <span id="add-partnermonitoringtemp" class="gray_btn" tabindex="-1"><spring:message code="editPartnergrant.link.partnerMonitoring" /></span>
					    </c:otherwise>
					</c:choose>   					
				</div>
	    		<a href="#" class="close-button gray_btn floatR" tabindex="-1">Close Form</a><br class="clear" />
	    	</div>
	        <div class="form_cont">		
				<table id="editPaymentPartnerInfo" class="fiveColTable" width="100%" cellspacing="1" cellpadding="0">
					<tr class="row">
						<td colspan="5" style="text-align: center;">
							<%@ include file="/common/messages.jsp" %>
						</td>
					</tr>
					<tr>
	                	<td id="space" class="label">&nbsp;</td>
	                	<td>&nbsp;</td>
	                	<td width="50">&nbsp;</td>
	                	<td class="label">&nbsp;</td>
	                	<td></td>
	              	</tr>
					<tr class="row">
						<td class="label2"><spring:message code="editPartnergrant.label.partner" /></td>
						<td class="input-field">
							<span style="width: 250px; float: left;">
							<form:select id="partner" path="partner.id" cssStyle="width: 248px;" cssClass="input-full-width-req text_blue" tabindex="1">
								<option value=""></option>
								<form:options items="${partnerList}" itemValue="id" itemLabel="partnerName" />
							</form:select>
							</span>
							<c:if test="${not empty allowedUiElements['Partner - Add']['Add Partner button']}">
								<sj:submit id="addPartner" nameKey="editPartnergrant.name.button.addeditpartner" cssStyle="width: 20%; min-width: 55px;" cssClass="blue_btn cancel" target="content" key="link.add" tabindex="-1"/>
							</c:if>
							<form:errors path="partner.id" cssClass="error" />
						</td>
						<td class="fiveColSpacer">&nbsp;</td>
						<%-- <td class="fiveColSpacer">
						<c:if test="${not empty allowedUiElements['Partner - Add']['Add Partner button']}">
							<sj:submit id="addPartner" nameKey="editPartnergrant.name.button.addeditpartner" cssClass="blue_btn cancel" target="content" key="link.add" tabindex="-1"/>
						</c:if>
							<form:errors path="partner.id" cssClass="error" /></td> --%>
						<td class="label2"><spring:message code="editPartnergrant.label.seniorProgramOfficer" /></td>
						<td class="input-field">
							<form:select id="seniorProgramOfficer" path="seniorProgramOfficer.id" cssClass="input-full-width-req text_blue" tabindex="9">
								<option value=""></option>
								<form:options items="${seniorProgramOfficerList}" itemValue="id" itemLabel="fullName" />
							</form:select>
							<form:errors path="seniorProgramOfficer.id" cssClass="error" />
						</td>
					</tr>
					<tr>
						<td class="label2"><spring:message code="editPartnergrant.label.costCenter" /></td>
						<td class="input-field"><form:select id="parentProjectId" path="parentProject.id" cssClass="input-full-width-req text_blue" tabindex="2">
								<option value=""></option>
								<form:options items="${parentProjectList}" itemValue="id" itemLabel="fullCostCenterNumber" />
							</form:select>
							<form:errors path="parentProject.id" cssClass="error" />
						</td>
						<td class="fiveColSpacer">&nbsp;</td>
						<td class="label2"><spring:message code="editPartnergrant.label.programOfficer" /></td>
						<td class="input-field">
							<form:select id="programOfficer" path="programOfficer.id" cssClass="input-full-width-req text_blue" tabindex="10">
								<option value=""></option>
								<form:options items="${programOfficerList}" itemValue="id" itemLabel="fullName" />
							</form:select>
							<form:errors path="programOfficer.id" cssClass="error" />
						</td>
					</tr>
					<tr class="row" style='display:none'>
									<td class="label"><spring:message code="editCipeproject.label.costCenter" /></td>
									<td class="input-field"><form:input path="costCenterNumber" id="costCenterNumber" maxlength="50" cssClass="input-full-width-req text_blue" tabindex="2" /> </td>
									 
					</tr>
					<tr>
						<td class="label2"><spring:message code="editPartnergrant.label.suffix" /></td>
						<td class="input-field"><form:select id="alphaidentifier" path="alphaidentifier" cssClass="input-full-width-req text_blue" tabindex="3">
								<option value=""></option>
								<form:option value="0A" label="0A"></form:option>
								<form:option value="0B" label="0B"></form:option>
								<form:option value="0C" label="0C"></form:option>
								<form:option value="0D" label="0D"></form:option>
								<form:option value="0E" label="0E"></form:option>
								<form:option value="0F" label="0F"></form:option>
								<form:option value="0G" label="0G"></form:option>
								<form:option value="0H" label="0H"></form:option>
								<form:option value="0I" label="0I"></form:option>
								<form:option value="0J" label="0J"></form:option>
								<form:option value="0K" label="0K"></form:option>
								<form:option value="0L" label="0L"></form:option>
								<form:option value="0M" label="0M"></form:option>
								<form:option value="0N" label="0N"></form:option>
								<form:option value="0O" label="0O"></form:option>
								<form:option value="0P" label="0P"></form:option>
								<form:option value="0Q" label="0Q"></form:option>
								<form:option value="0R" label="0R"></form:option>
								<form:option value="0S" label="0S"></form:option>
								<form:option value="0T" label="0T"></form:option>
								<form:option value="0U" label="0U"></form:option>
								<form:option value="0V" label="0V"></form:option>
								<form:option value="0W" label="0W"></form:option>
								<form:option value="0X" label="0X"></form:option>
								<form:option value="0Y" label="0Y"></form:option>
								<form:option value="0Z" label="0Z"></form:option>
							</form:select>
							<form:errors path="alphaidentifier" cssClass="error" />
						</td>
						<td class="fiveColSpacer">&nbsp;</td>
						<td class="label2"><spring:message code="editPartnergrant.label.programAssistant" /></td>
						<td class="input-field">
							<form:select id="programAssistant" path="programAssistant.id" cssClass="input-full-width-req text_blue" tabindex="11">
								<option value=""></option>
								<form:options items="${programAssistantList}" itemValue="id" itemLabel="fullName" />
							</form:select>
							<form:errors path="programAssistant.id" cssClass="error" />
						</td>
						
					</tr>
					
					<tr>
						<td class="label2"><spring:message code="editPartnergrant.label.projectID" /></td>
						<td class="input-field">
							<input id="projectIDDis" type="text" value="" readonly="readonly" class="input-full-width text_grey uneditable" tabindex="-1"/>
							<form:hidden path="projectID" maxlength="50" />
							<form:errors path="projectID" cssClass="error" />
						</td>
						<td class="fiveColSpacer">&nbsp;</td>
						<td class="label2"><spring:message code="editPartnergrant.label.partnerGrantFunds" /></td>
						<td class="input-field">
							<input id="partnerGrantFundsDis" type="text" class="input-full-width-req text_blue" tabindex="12" />
							<form:hidden path="partnerGrantFunds" cssClass="input-full-width-req text_blue" />
							<form:errors path="partnerGrantFunds" cssClass="error" />
						</td>						
					</tr>
					<tr class="row">
						<td class="label2"><spring:message code="editPartnergrant.label.startDate" /></td>
						<td class="input-field">
							<form:input path="partnerGrantStartDate" readonly="true" cssClass="input-full-width text_grey uneditable" tabindex="-1"/>
							<form:errors path="partnerGrantStartDate" cssClass="error" />
						</td>
						<td class="fiveColSpacer">&nbsp;</td>
						<td class="label2"><spring:message code="editPartnergrant.label.matchingFunds" /></td>
						<td class="input-field">
							<input id="matchingFundsDis" type="text" class="input-full-width text_white" tabindex="13" />
							<form:hidden path="matchingFunds" cssClass="input-full-width text_white" />
							<form:errors path="matchingFunds" cssClass="error" />
						</td>
					</tr>
					<tr>
						<td class="label2"><spring:message code="editPartnergrant.label.endDate" /></td>
						<td class="input-field">
							<form:input path="partnerGrantEndDate" readonly="true" cssClass="input-full-width text_grey uneditable" tabindex="-1"/>
							<form:errors path="partnerGrantEndDate" cssClass="error" />
						</td>
						<td class="fiveColSpacer">&nbsp;</td>
						<td class="label2"><spring:message code="editPartnergrant.label.totalFunds" /></td>
						<td class="input-field">
							<form:input path="totalDisbursedAmount" disabled="true" cssClass="input-full-width text_grey uneditable" tabindex="-1"/>
							<form:errors path="totalDisbursedAmount" cssClass="error" />
						</td>
					</tr>
					<tr class="row">
						<td class="label2"><spring:message code="editPartnergrant.label.nedIdentifier" /></td>
						<td class="input-field">
							<form:input path="nedIdentifier" maxlength="50" readonly="true" cssClass="input-full-width text_grey uneditable" tabindex="-1"/>
							<form:errors path="nedIdentifier" cssClass="error" />
						</td>
						<td class="fiveColSpacer">&nbsp;</td>
						<td class="label2"><spring:message code="editPartnergrant.label.fileLocation" /></td>
						<td class="input-field file-browser-container">
							<form:input path="fileLocation" maxlength="512" cssStyle="width: 70%;" cssClass="input-full-width text_white" tabindex="14" /> 
							<input id="chooseFileButton" style="width: 20%; min-width: 55px;" type="button" value="Edit" class="blue_btn" tabindex="-1"/>
							<form:errors path="fileLocation" cssClass="error" />
						</td>
					</tr>
					<tr>
						<td class="label2"><spring:message code="editPartnergrant.label.donorAwardID" /></td>
						<td class="input-field">
							<form:input id="donorawardId" cssStyle="width: 70%;" disabled="true" path="donoraward.donorAwardNumber"  cssClass="input-full-width text_grey uneditable " tabindex="-1"/>
							<form:hidden path="donoraward.id" id="donorawardRefId"/>
							<input type="button" class="blue_btn" style="width: 20%; min-width: 55px;" id="edit-donoraward" value="<spring:message code="link.view" />" tabindex="-1"/>
							<form:errors path="donoraward.id" cssClass="error" />
						</td>
						<td class="fiveColSpacer">&nbsp;</td>
						<td class="label2"><spring:message code="editPartnergrant.label.fiscalYear"/></td>
						<td class="input-field">
							<form:input path="fiscalYear" cssClass="input-full-width-req text_blue"  tabindex="15" />
							<form:errors path="fiscalYear" cssClass="error" />
						</td>
					</tr>
					<tr>
						<td class="label2"><spring:message code="editPartnergrant.label.donorName" /></td>
						<td class="input-field">
							<form:input id="donorId" path="" readonly="true" cssClass="input-full-width text_grey uneditable" tabindex="-1"/>
							<%-- <form:errors path="" cssClass="error" /> --%>
						</td>
						<td class="fiveColSpacer">&nbsp;</td>
						<td class="label2"><spring:message code="editPartnergrant.label.memo" /></td>
						<td class="input-field">
							<form:input path="memo" maxlength="5000" cssClass="input-full-width text_white" tabindex="16" />
							<form:errors path="memo" cssClass="error" />
						</td>
					</tr>
					<tr>
						<td class="label2"><spring:message code="editPartnergrant.label.grantStartDate" /></td>
						<td class="input-field">
							<form:input path="projectStartDate" cssClass="input-full-width-req text_blue" tabindex="4"/>
							<form:errors path="projectStartDate" cssClass="error" />
						</td>
						<td class="fiveColSpacer">&nbsp;</td>
						<td class="label2"><spring:message code="editPartnergrant.label.receivedingrantsforapproval" /></td>
						<td class="input-field">
							<form:input path="receivedingrantsforapproval" cssClass="input-full-width text_white" tabindex="17"/>
							<form:errors path="receivedingrantsforapproval" cssClass="error" />
						</td>
					</tr>
					<tr>
						<td class="label2"><spring:message code="editPartnergrant.label.grantEndDate" /></td>
						<td class="input-field">
							<form:input path="projectEndDate" cssClass="input-full-width-req text_blue" tabindex="5"/>
							<form:errors path="projectEndDate" cssClass="error" />
						</td>
						<td class="fiveColSpacer">&nbsp;</td>
						<td class="label2"><spring:message code="editPartnergrant.label.checkPerformed" /></td>
						<td class="input-field">
							<form:checkbox path="accountingQuestionnaireReceived" cssClass="input-full-width" value="true" tabindex="18"/>
							<form:errors path="accountingQuestionnaireReceived" cssClass="error" />
						</td>
					</tr>
					<tr>
						<td class="label2"><spring:message code="editPartnergrant.label.acronym" /></td>
						<td class="input-field">
							<form:input path="acronym" maxlength="50" cssClass="input-full-width-req text_blue"  tabindex="-1"/>
							<form:errors path="acronym" cssClass="error" />
						</td>
						<td class="fiveColSpacer">&nbsp;</td>
						<td class="label2"><spring:message code="editPartnergrant.label.blockTimeSheet" /></td>
						<td class="input-field">
							<form:checkbox path="terroristCheckPerformed" cssClass="input-full-width" value="true" tabindex="19"/>
							<form:errors path="terroristCheckPerformed" cssClass="error" />
						</td>
					</tr>
					<tr>
						<td class="label2"><spring:message code="editPartnergrant.label.projectTitle" /></td>
						<td class="input-field">
							<form:input path="projectTitle" maxlength="100" cssClass="input-full-width-req text_blue"  tabindex="-1"/>
							<form:errors path="projectTitle" cssClass="error" />
						</td>
						<td class="fiveColSpacer">&nbsp;</td>
						<td class="label2"><spring:message code="label.createdBy" /></td>
						<td class="input-field">
							<form:checkbox path="blockTimeSheet" cssClass="input-full-width" checked="true" tabindex="20"/>
							<form:errors path="blockTimeSheet" cssClass="error" />
						</td>
					</tr>
					<tr>
					<td class="label2"><spring:message code="editPartnergrant.label.region" /></td>
						<td class="input-field">
							<form:select path="region.id" cssClass="input-full-width-req text_blue" id="regions"  tabindex="7">
								<option value=""></option>
								<form:options items="${regionList}" itemValue="id" itemLabel="displayName" />
							</form:select>
							<form:errors path="region.id" cssClass="error" />
						</td>
						<td class="fiveColSpacer">&nbsp;</td>
						<td class="label2"><spring:message code="label.creationDate" /></td>
						<td class="input-field">
							<form:input readonly="true" path="createdBy.fullName" cssClass="input-full-width text_grey uneditable" tabindex="-1"/>
							<form:errors path="createdBy" cssClass="error" />
						</td>
					</tr>
					<tr>
						<td class="label2"><spring:message code="editPartnergrant.label.country" /></td>
						<td class="input-field">
							<form:select path="country.id" cssClass="input-full-width-req text_blue" id="countries"  tabindex="8">
								<option value=""></option>
								<form:options items="${countryList}" itemValue="id" itemLabel="displayName" />
							</form:select>
							<form:errors path="country.id" cssClass="error" />
						</td>
						<td class="fiveColSpacer">&nbsp;</td>
						<td class="label2"><spring:message code="label.updatedBy" /></td>
						<td class="input-field">
							<form:input readonly="true" path="creationDate" cssClass="input-full-width text_grey uneditable" tabindex="-1"/>
							<form:errors path="creationDate" cssClass="error" />
						</td>
					</tr>
					<tr>
						<td class="label2"><spring:message code="editPartnergrant.label.status" /></td>
						<td class="input-field">
							<form:select id="status" path="cipeprojectstatus.id" cssClass="input-full-width-req text_blue"  tabindex="6">
								<form:options items="${cipeprojectstatusList}" itemValue="id" itemLabel="displayName" />
							</form:select>
							<form:errors path="cipeprojecttype.id" cssClass="error" />
						</td>
						
						<td class="fiveColSpacer">&nbsp;</td>
						<td class="label2"><spring:message code="label.updationDate" /></td>
						<td class="input-field">
							<form:input readonly="true" path="updatedBy.fullName" cssClass="input-full-width text_grey uneditable" tabindex="-1"/>
							<form:errors path="updatedBy" cssClass="error" />
						</td>
					</tr>
					<tr>
						<td class="label2">&nbsp;</td>
						<td>&nbsp;</td>
						
						<td class="fiveColSpacer">&nbsp;</td>
						<td class="label2"><spring:message code="label.updationDate" /></td>
						<td class="input-field">
							<form:input readonly="true" path="updationDate" cssClass="input-full-width text_grey uneditable" tabindex="-1"/>
							<form:errors path="updationDate" cssClass="error" />
						</td>
					</tr>
					<tr><td>&nbsp<td></tr>
					<tr class="row">
						<td class="input-field" colspan="7" style="text-align: center;">
							<input id="cancelButton" type="button" class="gray_btn" value="<spring:message code='button.cancel' />" tabindex="-1"/>
                         	<security:authorize ifAnyGranted="ROLE_ADMIN,ROLE_GRANTS">
								<input id="editButton" class="blue_btn" type="button" value="Edit" tabindex="-1" />
                          	</security:authorize>
                            <c:choose>
                             	 <c:when test="${!empty mode && 'addPartnerGrant' == mode}">
                                 	<input id="showConfirmAddNarativeReport" class="blue_btn" type="button" value="Save" tabindex="-1"/>
                                	<sj:submit id="submitFormButton" target="editPartnergrantDiv" validate="true" tabindex="-1" cssClass="hiddenSubmitButton"/>
                              	</c:when>
                              	<c:otherwise>
                                	<sj:submit id="partnergrantFormSubmit" cssClass="blue_btn" target="editPartnergrantDiv" key="editPartnergrant.button.save" validate="true" tabindex="-1"/>
                              	</c:otherwise>
                            </c:choose>              
						</td>
					</tr>
					<!-- 
					<tr class="row">
						<td class="label2"><spring:message code="editPartnergrant.label.override" /></td>
						<td class="input-field"><form:checkbox path="override" cssClass="input-full-width" value="true" /></td>
						<td><form:errors path="override" cssClass="error" /></td>
					</tr>
					<tr>
						<td class="label2"><spring:message code="editPartnergrant.label.overrideAmount" /></td>
						<td class="input-field">
							<input id="overrideAmountDis" type="text" class="input-full-width text_white" />
							<form:hidden path="overrideAmount" cssClass="input-full-width text_white" />
							<form:errors path="overrideAmount" cssClass="error" />
						</td>
					</tr>
					<tr>
						<td class="label2"><spring:message code="editPartnergrant.label.overridePeriodStartDate" /></td>
						<td class="input-field"><form:input path="overridePeriodStartDate" cssClass="input-full-width-req text_blue" /></td>
						<td><form:errors path="overridePeriodStartDate" cssClass="error" /></td>
					</tr>
					<tr>
						<td class="label2"><spring:message code="editPartnergrant.label.overridePeriodEndDate" /></td>
						<td class="input-field"><form:input path="overridePeriodEndDate" cssClass="input-full-width-req text_blue" /></td>
						<td><form:errors path="overridePeriodEndDate" cssClass="error" /></td>
					</tr>
					 -->
				</table>
			</div>
		</div>   
	</form:form>
</div>
